<?php

class DefaultController extends Controller
{
	public $layout='//layouts/main';
	
	public function actionIndex()
	{
		$customer = array();
		$customerquote = array();
		$emailPost = "";
		$tradenum = "";
		$price = 0;
		$paymentMethod = "";
		$txtStatus = "";
		
		if(!empty($_POST)){
			
			
			if(!empty($_POST['email'])) $emailPost = $_POST['email'];
			if(!empty($_POST['tradenum'])) $tradenum = $_POST['tradenum'];
			$customerquote = Customerquote::model()->findByPk($tradenum);
			if(!empty($customerquote)){
				$price = $customerquote->price;
				$paymentMethod = $customerquote->paymentMethod;
				$txtStatus = $customerquote->getStatus($customerquote->id);
				$customer = array();
				if(!empty($customerquote->customer)){
					$customer = $customerquote->customer;
					// dump($customer,false);
				}
			}
			// dump($customerquote,false);
			// dump($_POST,false);
		}
		$statusResult = false;
		if(!empty($customer) && $customer->email == $emailPost){
			$statusResult = true;
		}
		$this->render('index',array(
			'customerquote'=>$customerquote,
			'customer'=>$customer,
			'statusResult'=>$statusResult,
			'tradenum'=>$tradenum,
			'emailPost'=>$emailPost,
			'price'=>$price,
			'paymentMethod'=>$paymentMethod,
			'txtStatus'=>$txtStatus,
		));
	}
}